//
//  LGVisitorViewController.swift
//  LGWeibo
//
//  Created by 李更 on 8/10/16.
//  Copyright © 2016 itcast. All rights reserved.
//

import UIKit

class LGVisitorViewController: UIViewController {
    
    //判断用户是否登录
    var isLogin : Bool = LGUserAccountViewModel.sharedTools.isLogin
    
    //访客视图
    var visitorView : LGVisitorView?
    
    
    
    override func loadView() {
        if isLogin {
            view = tableView
        }else{
            
            setupNav()
           visitorView = LGVisitorView()
            //实例化闭包02
            visitorView?.closure = {
                //04打印
              self.loginAction()
            }
            
            view = visitorView
        }
    }
    
    func setupNav() {
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: "loginAction")
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录", style: UIBarButtonItemStyle.Plain, target: self, action: "loginAction")
    }
    
    //点击事件
    func loginAction(){
       
        let oauthVc = LGOAuthViewController()
       
       presentViewController( UINavigationController(rootViewController: oauthVc), animated: true, completion: nil)
        
    }
    
    
    

    override func viewDidLoad() {
        super.viewDidLoad()

    }
    lazy var tableView : UITableView = UITableView()
}
